package indiwood.controller;

import indiwood.model.CinemaVO;
import indiwood.model.DirectorListVO;
import indiwood.model.ShowingListVO;
import indiwood.model.service.MovieService;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
@Controller
@RequestMapping("/movie")
public class MovieController extends MultiActionController {
	@Resource(name = "movieServiceImpl")
	private MovieService movieService;
	@RequestMapping("/{viewId}_view.do")
	public String showView(@PathVariable("viewId") String viewId) {	
		return viewId+"_view.movie";
	}
	@RequestMapping("/showingList.do")
	public ModelAndView showingList(String pageNo){
		ShowingListVO sListVo = movieService.getShowingList(pageNo);
		//System.out.println(sListVo);
		return new ModelAndView("showingList.movie", "sListVo", sListVo);
	}
	@RequestMapping("/soonList.do")
	public ModelAndView soonList(String pageNo){
		ShowingListVO sListVo = movieService.getSoonList(pageNo);
		return new ModelAndView("soonList.movie", "sListVo", sListVo);
	}
	@RequestMapping("/moviefinder.do")
	public ModelAndView movieFinder(){			
		return new ModelAndView("moviefinder.movie");
	}
	@RequestMapping("/directorList.do")
	public ModelAndView directorList(String pageNo){
		DirectorListVO dlistvo = movieService.directorList(pageNo);
		return new ModelAndView("directorList.movie", "dlistvo", dlistvo);
	}
	@RequestMapping("/cinemaList.do")
	public ModelAndView cinemaList(){
		CinemaVO cvo = movieService.defaultCinema();
		HashMap<String, Object> cinemaMap = movieService.cinemaListBylatlng(cvo);
		return new ModelAndView("cinemaList.movie", "cinemaMap", cinemaMap);
	}
	@RequestMapping("/cinemaListBylatlng.do")
	public ModelAndView cinemaListBylatlng(CinemaVO cvo){
		HashMap<String, Object> cinemaMap = movieService.cinemaListBylatlng(cvo);
		return new ModelAndView("cinemaList.movie", "cinemaMap", cinemaMap);
	}
	@RequestMapping("/cinemaContent.do")
	@ResponseBody
	public CinemaVO cinemaContent(int cinemaNo){
		CinemaVO cinemaContent = movieService.cinemaContent(cinemaNo);
		return cinemaContent;
	}
	@RequestMapping("/director_content.do")
	public ModelAndView directorContent(int directorNo){
		HashMap<String, Object> directorDetailMap = new HashMap<String, Object>();
		directorDetailMap = movieService.directorContent(directorNo);
		return new ModelAndView("director_content.movie", "directorDetailMap", directorDetailMap);
	}
	@RequestMapping("/movie_content.do")
	public ModelAndView movieContent(int movieNo){
		Map<String, Object> mContentMap = movieService.movieContent(movieNo);
		return new ModelAndView("movie_content.movie", "mContentMap", mContentMap);
	}
}